package view;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import controller.ClientWindowController;

public class ClientWindow extends JDialog {

	private final JPanel contentPanel = new JPanel();
	public static JTextField textField;
	public static JTextField textField_1;
	public static JTextField textField_2;
	public static JTextField textField_3;
	public static JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			ClientWindow dialog = new ClientWindow();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public ClientWindow() {
		setBounds(100, 100, 508, 322);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		{
			textField = new JTextField();
			textField.setBounds(10, 37, 86, 20);
			contentPanel.add(textField);
			textField.setColumns(10);
		}
		{
			textField_1 = new JTextField();
			textField_1.setBounds(106, 37, 86, 20);
			contentPanel.add(textField_1);
			textField_1.setColumns(10);
		}
		{
			textField_2 = new JTextField();
			textField_2.setBounds(202, 37, 86, 20);
			contentPanel.add(textField_2);
			textField_2.setColumns(10);
		}
		{
			textField_3 = new JTextField();
			textField_3.setBounds(298, 37, 86, 20);
			contentPanel.add(textField_3);
			textField_3.setColumns(10);
		}
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 102, 472, 146);
		contentPanel.add(scrollPane);
		
		table = new JTable();
		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		table.setAutoscrolls(true);
		
		scrollPane.setViewportView(table);
		
		JLabel label = new JLabel("Фамилия:");
		label.setBounds(10, 11, 86, 14);
		contentPanel.add(label);
		
		JLabel label_1 = new JLabel("Имя:");
		label_1.setBounds(106, 11, 86, 14);
		contentPanel.add(label_1);
		
		JLabel label_2 = new JLabel("Отчество:");
		label_2.setBounds(202, 11, 86, 14);
		contentPanel.add(label_2);
		
		JLabel label_3 = new JLabel("Телефон:");
		label_3.setBounds(298, 11, 86, 14);
		contentPanel.add(label_3);
		
		JButton btnNewButton = new JButton("Найти");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ClientWindowController newController = new ClientWindowController();
				newController.findClient();
			}
		});
		btnNewButton.setBounds(7, 68, 475, 23);
		contentPanel.add(btnNewButton);
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton cancelButton = new JButton("Закрыть");
				cancelButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						setVisible(false);
					}
				});
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
	}
	
	public static String getTextField() {
		return textField.getText();
	}
	
	public static String getTextField_1() {
		return textField_1.getText();
	}
	
	public static String getTextField_2() {
		return textField_2.getText();
	}
	public static String getTextField_3() {
		return textField_3.getText();
	}
}
